**** OPEN OUTPUT LOG FILE  *****


log using "C:\Users\User\Dropbox\Administration of UI Programs in the American States (Ji-Hyeun Hong)\Implementation Delay Project (Paper #2)\JPART Conditional Acceptance\Empirics\Output\Implementation Delay.APPENDIX A.DESCRIPTIVES.04-21-2025.smcl", replace 

use "C:\Users\User\Dropbox\Administration of UI Programs in the American States (Ji-Hyeun Hong)\Implementation Delay Project (Paper #2)\JPART Conditional Acceptance\Empirics\Data\Implementation Delay.MANUSCRIPT DATABASE.04-18-2025.dta", replace

****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
* TABLE A1.1. IT Reform States : Descriptive Statistics for Variables Analyzed in Manuscript 

qui: npregress series delay_14days  itmod_monthcount i.agencyhead_gov0 if itmod_adopt_state==1, asis(agencyhead_tenure automationrate wstaff_load staff_tdiff unemp_rate  function_sup_avgsalreal i.stateid i.year adoptcohort_2002_itadopt  adoptcohort_2004_itadopt  adoptcohort_2006_itadopt adoptcohort_2007_itadopt adoptcohort_2009_itadopt adoptcohort_2010_itadopt  adoptcohort_2013_itadopt adoptcohort_2014_itadopt adoptcohort_2015_itadopt adoptcohort_2016_itadopt adoptcohort_2017_itadopt adoptcohort_2018_itadopt  adoptcohort_2020_itadopt adoptcohort_2021_itadopt)   vce(bootstrap, seed(123) rep(5))

*
*
format delay_14days delay_29plusdays itmod_monthcount agencyhead_gov0 agencyhead_govord_1 agencyhead_govord_2 agencyhead_tenure automationrate wstaff_load staff_tdiff unemp_rate  function_sup_avgsalreal %9.2fc

sum delay_14days delay_29plusdays itmod_monthcount agencyhead_gov0 agencyhead_govord_1 agencyhead_govord_2 agencyhead_tenure automationrate wstaff_load staff_tdiff unemp_rate  function_sup_avgsalreal if e(sample), format


* Binary Variable: Prior Government Experience
tab agencyhead_gov0   if e(sample)

* Categorical Variables Frequencies: Prior Administrative–Specific Government Experience
tab agencyhead_govord_1  if e(sample)

* Categorical Variables Frequencies: Prior Agency–Specific Government Experience
tab agencyhead_govord_2 if e(sample)

xtsum delay_14days delay_29plusdays if e(sample)

****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
* TABLE A1.2. Non-IT Reform States : Descriptive Statistics for Variables Analyzed in Manuscript 

format delay_14days delay_29plusdays itmod_monthcount agencyhead_gov0 agencyhead_govord_1 agencyhead_govord_2 agencyhead_tenure automationrate wstaff_load staff_tdiff unemp_rate  function_sup_avgsalreal %9.2fc

sum delay_14days delay_29plusdays itmod_monthcount agencyhead_gov0 agencyhead_govord_1 agencyhead_govord_2 agencyhead_tenure automationrate wstaff_load staff_tdiff unemp_rate  function_sup_avgsalreal if itmod_adopt_state!=1, format


* Binary Variable: Prior Government Experience
tab agencyhead_gov0   if itmod_adopt_state!=1

* Categorical Variables Frequencies: Prior Administrative–Specific Government Experience
tab agencyhead_govord_1  if itmod_adopt_state!=1

* Categorical Variables Frequencies: Prior Agency–Specific Government Experience
tab agencyhead_govord_2 if itmod_adopt_state!=1

xtsum delay_14days delay_29plusdays if itmod_adopt_state!=1

****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
* FIGURE A1: Different Types of Prior Government Experiences of Agency Heads (60 Months Before and After the IT Reform)


order state st_postal stateid year month monthyear itmod_monthcount agencyhead_tenure

keep if itmod_adopt_state==1



* New Variable "itmod_when": "Month-Year When the itmod_monthcount==1 (First Month of IT Reform of State i)
gen itmod_when1 = monthyear if itmod_monthcount==1
bysort stateid: egen itmod_when = max(itmod_when1)
drop itmod_when1

* New Variable "timeline": Set the first month of IT reform as "t" and identify month-years that fall between the range of t-60 to t+60.
gen timeline = itmod_monthcount-1 if itmod_monthcount>0
replace timeline = monthyear - itmod_when if itmod_adopt_state==1 & itmod_monthcount==0

sort stateid monthyear

* agencyhead identifier 
egen agencyhead_id = group(stateid agencyhead_name)

* New Variables "agencyhead_tenuremax" & "agencyhead_tenuremin" : Set the first month of IT reform as "t" and transform the start and the end month-years of agency heads relative to this t. 
bysort agencyhead_id stateid: egen agencyhead_tenuremax = max(agencyhead_tenure)
bysort agencyhead_id stateid: egen agencyhead_tenuremin = min(agencyhead_tenure)


drop if timeline < -60 | timeline > 60


gen tenure_begin=.
replace tenure_begin=timeline if agencyhead_tenure ==agencyhead_tenuremin

gen tenure_end=.
replace tenure_end=timeline if agencyhead_tenure ==agencyhead_tenuremax

sort stateid monthyear

bysort agencyhead_id: egen tenure_begin1 = max(tenure_begin)
bysort agencyhead_id: egen tenure_end1 = max(tenure_end)


sort stateid monthyear

replace tenure_end1 = 60 if missing(tenure_end1)
replace tenure_begin1 = -60 if missing(tenure_begin1)

sort stateid monthyear


*
*
*
bysort agencyhead_id: drop if _n!=1
tab agencyhead_govord_1

sort stateid monthyear
*
*
*
*
* Realign panels in the order of their IT modernization dates
bysort stateid: egen t_60when= min(itmod_when)
sort t_60when

gen no = 1 if sum(t_60when!=t_60when[_n-1])==1

 forvalues i = 2/30 {
	replace no = `i' if sum(t_60when!=t_60when[_n-1])==`i'
 }

sort no
order no

list no state
*
*
*
*
*
*
*
*
replace tenure_begin1 = tenure_begin1 - 0.5
replace tenure_end1 = tenure_end1 + 0.5

replace no=12 if state=="Nevada"
replace no=no+2 if no>=11 & state!="Michigan" & state!="Nevada"

replace no=18 if state=="Idaho"
replace no=no+1 if no>17 & state!="Idaho"
*
*
twoway (rbar tenure_begin1 tenure_end1 no if agencyhead_govord_1 == 0 , color(stc10) lcolor(black) lwidth(vthin) barwidth(.6) horizontal yscale(reverse r(1 27))  xsize(5) ysize(8) ///
xlabel(-60 "t-60" -30 "t-30" 0 "t"  30 "t+30" 60 "t+60", labsize(small)) ylabel(1 "New Mexico" 2 "Ohio" 3 "Utah" 4 "Nebrasksa" 5 "Minnesota" 6 "Mississippi" 7 "New Hampshire" 8 "Illinois" 9 "New Mexico 2" 10 "Massachusetts" 11 "Michigan" 12 "Nevada" 13 "California" 14 "Florida" 15 "Indiana" 16 "Nebraska 2" 17 "Louisiana" 18 "Idaho" 19 "Tennessee" 20 "Missouri" 21 "Washington" 22 "South Carolina" 23 "Maine" 24 "Wyoming" 25 "North Carolina" 26 "Alabama" 27 "Maryland" 28 "Colorado" 29 "Pennsylvania" 30 "Virginia", labsize(small)) ///
legend(pos(6) col(1) keygap(1) size(small) symysize(vsmall) symxsize(vsmall) lab(1 "No Prior Government") lab(2 "Prior Political Related Only") lab(3 "Prior Appointed Administrative") lab(4 "Prior Civil Administrative")) xline(0, lcolor(black))) ///
(rbar tenure_begin1 tenure_end1 no if agencyhead_govord_1 == 1 , color(stgreen) lcolor(black) lwidth(vthin) barwidth(.6) horizontal yscale(reverse r(1 27))) ///
(rbar tenure_begin1 tenure_end1 no if agencyhead_govord_1 == 2 , color(stblue) lcolor(black) lwidth(vthin) barwidth(.6) horizontal yscale(reverse r(1 27))) ///
(rbar tenure_begin1 tenure_end1 no if agencyhead_govord_1 == 3 , color(stred) lcolor(black) lwidth(vthin) barwidth(.6) horizontal yscale(reverse r(1 27))), title("t=Month-Year of IT Reform", size(small)) ytitle("") xtitle("") scheme(stcolor)


log close
